﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DefektaiApp
{
    public partial class frmIdRequestCombo : Form
    {
        public frmIdRequestCombo(string frmTitle, string requestText)
        {
            InitializeComponent();
            this.Text = frmTitle;
            lblRequest.Text = requestText;
            Program.pubString = string.Empty;            
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            Program.pubInt = Convert.ToInt32(cmbSelect.SelectedValue);
            Program.pubString = cmbSelect.Text;
            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void frmIdRequestCombo_Load(object sender, EventArgs e)
        {
            string sqlStr = "SELECT pavadinimas, id FROM Linijos WHERE isActive=True ORDER BY pavadinimas;";
            cmbSelect.DataSource = DbHelper.fillDataTable(sqlStr);
            cmbSelect.DisplayMember = "pavadinimas";
            cmbSelect.ValueMember = "id";
            cmbSelect.SelectedValue = Program.pubInt;
            Program.pubInt = -1;
        }
    }
}
